package com.yingside.collection.game;

public abstract class Enemy {
	public String name;
	public int hp;
	public int attack;
	public int defence;
	public int money;

	public void injured(Hero h){
		int lostLife =GameUtil.getLostLife(h.getAttack(), this.defence);


		this.hp -= lostLife;

		if(this.hp <= 0){
			System.out.println(this.name + "死亡...");
			//在函数中,如果想让代码不再继续往下执行,可以直接使用return返回
			//由于这个函数没有返回值,所以直接写一个return,就表示函数在这里直接结束
			//而且注意,这种写法肯定要和if判断配合起来一起使用
			return;
		}

		System.out.println("======怪兽受伤======");
		System.out.println("英雄的攻击力:" + h.getAttack());
		System.out.println("怪兽的防御力:" + this.defence);
		System.out.println(this.name + "受到"+lostLife+"点伤害");

		System.out.println(this.name + "剩余血量:" + this.hp);
	}

	public abstract void response(Hero h);

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getHp() {
		return hp;
	}
	public void setHp(int hp) {
		this.hp = hp;
	}
	public int getAttack() {
		return attack;
	}
	public void setAttack(int attack) {
		this.attack = attack;
	}
	public int getDefence() {
		return defence;
	}
	public void setDefence(int defence) {
		this.defence = defence;
	}

	public int getMoney() {
		return money;
	}

	public void setMoney(int money) {
		this.money = money;
	}


}

